import request from "../utils/request"
// 获取文章列表
export function getList (data) {
  return request.get('/index/list', {
    params: data
  })
}
//获取文章详情
export function getDetail (id) {
  return request.get('/index/show/?id=' + id)
}
// 发布文章
export function addArticle (obj) {
  return request.post('/user/addArticle', obj)
}
//点赞
export function updateLike (obj) {
  return request.get('/user/userDataHandle', {
    params: {
      type: 2,
      article_id: obj.id,
      action: obj.action
    }
  })
}
// 收藏
export function updateCollect (obj) {
  return request.get('/user/userDataHandle', {
    params: {
      type: 1,
      article_id: obj.id,
      action: obj.action
    }
  })
}

// 获取收藏和点赞列表
export const getUserDataList = (obj) => {
  return request.get('/user/userDataList', {
    params: {
      type: obj.type,
      page: obj.page, 
      limit: obj.limit
    }
  })
}
// 获取我的文章列表
export const getMyArticle = (obj) => {
  return request.get('/user/myArticle', {
    params: {
      page: obj.page,
      limit: obj.limit
    }
  })
}
// 删除文章
export const delArticle = (id) => {
  return request.get('/user/delArticle?id='+id,)
}

// 修改文章
export function editArticle (obj) {
  return request.post('/user/editArticle', obj)
}
